package com.kirayous.task.controller;

import com.google.gson.Gson;
import com.kirayous.task.entity.Task1;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/task1")
public class task1Controller {

    @GetMapping("/echo")
    public String echo()
    {
/*        使用Gson而不是默认自带的JackSon*/
        Gson gson=new Gson();
        Task1 task1=new Task1();
        task1.setId(1);
        task1.setUsername("KiraYous");
        task1.setPassword("123456");
        return gson.toJson(task1);
    }

    @GetMapping("/test")
    public String echo2()
    {
        return "Hello World";
    }
}
